/*
 * @Author: Await
 * @Date: 2024-11-07 10:23:38
 * @LastEditors: Await
 * @LastEditTime: 2024-12-25 10:30:44
 * @Description: 请填写简介
 */
import {request} from '../request';

/**
 * Login
 *
 * @param userName User name
 * @param password Password
 */
export function fetchLogin(userName: string, password: string) {
    return request<Api.Auth.LoginToken>({
        url: '/Users/Login',
        method: 'post',
        data: {
            userName,
            password
        }
    });
}

/** Get user info */
export function fetchGetUserInfo() {
    return request<Api.Auth.UserInfo>({url: '/Users/UserInfo'});
}

/**
 * 刷新令牌
 *
 * @param refreshToken Refresh token
 */
export function fetchRefreshToken(refreshToken: string) {
    return request<Api.Auth.LoginToken>({
        url: '/auth/refreshToken',
        method: 'post',
        data: {
            refreshToken
        }
    });
}

/**
 * return custom backend error
 *
 * @param code error code
 * @param msg error message
 */
export function fetchCustomBackendError(code: string, msg: string) {
    return request({url: '/auth/error', params: {code, msg}});
}
